package cn.lgp6.ziyou_util.excel.controller;
import cn.lgp6.ziyou_util.common.controller.BaseController;
import cn.lgp6.ziyou_util.common.result.RequestResult;
import cn.lgp6.ziyou_util.common.result.RequestResultBuilder;
import cn.lgp6.ziyou_util.excel.entity.vo.ExcelToMysqlFormVO;
import cn.lgp6.ziyou_util.excel.service.ExcelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.Session;

@RestController
public class ExcelController extends BaseController {
    @Autowired
    private ExcelService excelService;

    @PostMapping("/importExcelToMysql")
    @ResponseBody
    public synchronized RequestResult  importExcelToMysql(ExcelToMysqlFormVO excelToMysqlFormVO){
        if (!objectFieldsIsNotNull(excelToMysqlFormVO))
            return RequestResultBuilder.error("不合法的参数,请检查是否有参数留空");
        return excelService.importExcelToMysql(excelToMysqlFormVO);
    }

}
